home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1320 / 1320.xpi / chrome / gmanager.jar / content / overlay.xml < prev    next >
Extensible Markup Language  |  2010-01-22  |  5KB  |  173 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!-- 
  4.   Gmail Manager
  5.   By Todd Long <longfocus@gmail.com>
  6.   http://www.longfocus.com/firefox/gmanager/
  7.  -->
  8.  
  9. <bindings xmlns="http://www.mozilla.org/xbl"
  10.         xmlns:xbl="http://www.mozilla.org/xbl"
  11.         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  12.         
  13.     <binding id="gmanager-account-info">
  14.         <content context="_child" tooltip="_child">
  15.             <children includes="menupopup|tooltip"/>
  16.             
  17.             <xul:hbox align="center">
  18.                 <xul:image class="gmanager-icon"
  19.                         xbl:inherits="iconsize,icontype,status,newMail"/>
  20.                         
  21.                 <xul:label class="gmanager-unread"
  22.                         value=""
  23.                         xbl:inherits="value=unread"/>
  24.                         
  25.                 <xul:label class="gmanager-alias"
  26.                         value=""
  27.                         xbl:inherits="value=alias"/>
  28.             </xul:hbox>
  29.         </content>
  30.         
  31.         <implementation implements="nsIObserver">
  32.             <constructor>
  33.               <![CDATA[
  34.                 var observer = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  35.                 observer.addObserver(this, gmanager_Accounts.NOTIFY_STATE, false);
  36.               ]]>
  37.             </constructor>
  38.             
  39.             <destructor>
  40.               <![CDATA[
  41.                 this.destroy();
  42.               ]]>
  43.             </destructor>
  44.             
  45.             <property name="account"
  46.                     onget="return this._account;">
  47.                     
  48.                 <setter>
  49.                   <![CDATA[
  50.                     this._account = val;
  51.                     this.setAttribute("id", "gmanager-toolbar-panel-" + val.email);
  52.                     this.updatePosition();
  53.                   ]]>
  54.                 </setter>
  55.             </property>
  56.             
  57.             <property name="displayAccount"
  58.                     onget="return this._displayAccount;">
  59.                     
  60.                 <setter>
  61.                   <![CDATA[
  62.                     this._displayAccount = val;
  63.                     this.updateDisplay();
  64.                   ]]>
  65.                 </setter>
  66.             </property>
  67.             
  68.             <method name="destroy">
  69.                 <body>
  70.                   <![CDATA[
  71.                     try {
  72.                       var observer = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  73.                       observer.removeObserver(this, gmanager_Accounts.NOTIFY_STATE);
  74.                     } catch(e) {}
  75.                     
  76.                     if (this.parentNode)
  77.                       this.parentNode.removeChild(this);
  78.                   ]]>
  79.                 </body>
  80.             </method>
  81.             
  82.             <method name="updateDisplay">
  83.                 <body>
  84.                   <![CDATA[
  85.                     if (this._displayAccount)
  86.                     {
  87.                       var unread = this._displayAccount.unread;
  88.                       
  89.                       this.setAttribute("icontype", this._displayAccount.type);
  90.                       this.setAttribute("status", gmanager_Utils.toStyleStatus(this._displayAccount.status));
  91.                       this.setAttribute("newMail", unread > 0 ? "true" : "false");
  92.                       this.setAttribute("unread", !this._displayAccount.getBoolPref("toolbar-account-hide-unread-count") && this._displayAccount.loggedIn ? unread : "");
  93.                       this.setAttribute("alias", !this._displayAccount.getBoolPref("toolbar-account-hide-alias") ? gmanager_Utils.toUnicode(this._displayAccount.alias) : "");
  94.                     }
  95.                   ]]>
  96.                 </body>
  97.             </method>
  98.             
  99.             <method name="updatePosition">
  100.                 <body>
  101.                   <![CDATA[
  102.                     if (this._account)
  103.                     {
  104.                       var isToolbarDisplay = this._account.getBoolPref("toolbar-display");
  105.                       
  106.                       if (isToolbarDisplay)
  107.                       {
  108.                         var toolbar = document.getElementById(this._account.getCharPref("toolbar-toolbar-id"));
  109.                         var toolbarPosition = this._account.getIntPref("toolbar-specific-position");
  110.                         
  111.                         if (toolbar === null)
  112.                           toolbar = document.getElementById("status-bar");
  113.                         
  114.                         if (this._account.getCharPref("toolbar-placement") == "always-last" || (toolbar.childNodes && toolbar.childNodes.length <= toolbarPosition))
  115.                           toolbar.appendChild(this);
  116.                         else
  117.                           toolbar.insertBefore(this, toolbar.childNodes[toolbarPosition]);
  118.                       }
  119.                       
  120.                       this.setAttribute("hidden", !isToolbarDisplay);
  121.                     }
  122.                   ]]>
  123.                 </body>
  124.             </method>
  125.             
  126.             <method name="observe">
  127.                 <parameter name="aSubject"/>
  128.                 <parameter name="aTopic"/>
  129.                 <parameter name="aData"/>
  130.                 <body>
  131.                   <![CDATA[
  132.                     if (aTopic == gmanager_Accounts.NOTIFY_STATE)
  133.                     {
  134.                       // aSubject : null
  135.                       // aTopic   : gmanager_Accounts.NOTIFY_STATE
  136.                       // aData    : email|status (e.g. longfocus@gmail.com|10)
  137.                       
  138.                       var email = (aData ? aData.split("|")[0] : null);
  139.                       
  140.                       if (this._displayAccount && this._displayAccount.email == email)
  141.                         this.updateDisplay();
  142.                     }
  143.                   ]]>
  144.                 </body>
  145.             </method>
  146.         </implementation>
  147.     </binding>
  148.     
  149.     <binding id="gmanager-toolbar-menuitem"
  150.             extends="chrome://global/content/bindings/menu.xml#menuitem">
  151.             
  152.         <content type="radio">
  153.             <xul:hbox class="menu-iconic-left"
  154.                     align="center"
  155.                     pack="center"
  156.                     xbl:inherits="selected,checked">
  157.                     
  158.                 <xul:image class="menu-iconic-icon"
  159.                         xbl:inherits="src=image"/>
  160.             </xul:hbox>
  161.             
  162.             <xul:label class="menu-iconic-text"
  163.                     flex="1"
  164.                     xbl:inherits="value=alias"/>
  165.                     
  166.             <xul:label xbl:inherits="value=unread"/>
  167.             
  168.             <xul:image class="gmanager-icon"
  169.                     iconsize="small"
  170.                     xbl:inherits="icontype,status,newMail"/>
  171.         </content>
  172.     </binding>
  173. </bindings>